//
//  SRHeaderCellTableViewCell.m
//  SportRing
//
//  Created by icelee on 14-11-1.
//  Copyright (c) 2014年 HotOne. All rights reserved.
//

#import "SRTableViewCell.h"
#import <QuartzCore/QuartzCore.h>

@implementation SRTableViewCellModel

- (id)initWithTipImage:(UIImage *)tipImage title:(NSString*)title content:(NSString*)content switchValue:(BOOL)value
{
    self = [super init];
    if (self)
    {
        self.tipImage = tipImage;
        self.title = title;
        self.content = content;
        self.swichValue = value;
        
    }
    return self;
    
}


@end

@interface SRTableViewCell()

@property (nonatomic, weak)IBOutlet UIView *customBackgroundView;

@end

@implementation SRTableViewCell

- (void)awakeFromNib {
    // Initialization code
    
    //圆角
    self.customBackgroundView.layer.cornerRadius = 3;
    
    //阴影
    CALayer * layer = [self.customBackgroundView layer];
    [layer setShadowOffset:CGSizeMake(0, 1)];
    [layer setShadowRadius:1.0];
    [layer setShadowOpacity:0.3];
    [layer setShadowColor:[UIColor lightGrayColor].CGColor];
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

- (void)hideSwitchButton
{
    self.swith.hidden = YES;
}

- (void)showSwitchButton
{
    self.swith.hidden = NO;
}


- (void)setSRTableViewCellData:(SRTableViewCellModel *)model
{
    self.tipImageView.image = model.tipImage;
    self.titleLabel.text = model.title;
    self.contentLabel.text = model.content;
    self.swith.on = model.swichValue;
}

- (IBAction)switchAction:(id)sender
{
    UISwitch *sw = (UISwitch *)sender;
    
    if (sw.tag == SR_SWITCH_TYPE_SMS)
    {
        if (_srcDelegate && [_srcDelegate respondsToSelector:@selector(switchValue:type:)])
        {
            [_srcDelegate switchValue:sw.on type:SR_SWITCH_TYPE_SMS];
        }
        
    }
    if (sw.tag == SR_SWITCH_TYPE_PHONE)
    {
        if (_srcDelegate && [_srcDelegate respondsToSelector:@selector(switchValue:type:)])
        {
            [_srcDelegate switchValue:sw.on type:SR_SWITCH_TYPE_PHONE];
        }
        
    }
    
}

@end
